package com.ricky.onlineShop.read.trading.service.impl;

import com.ricky.admin.util.LoginUserUtils;
import com.ricky.common.utils.DateUtils;
import com.ricky.onlineShop.read.trading.mapper.TradingOrderMapper;
import com.ricky.onlineShop.read.trading.service.TradingOrderReadService;
import com.ricky.onlineShop.read.trading.service.TradingPerformanceReadService;
import com.ricky.onlineShop.shop.trading.pojo.TradingOrder;
import com.ricky.onlineShop.shop.trading.pojo.TradingPerformance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 网店订单Service业务层处理
 *
 * @author ricky
 * @Date 2024-07-08
 */
@Service
public class TradingOrderReadServiceImpl implements TradingOrderReadService {
    @Autowired
    private TradingOrderMapper tradingOrderMapper;

    /**
     * 查询网店订单
     *
     * @param id 网店订单主键
     * @return 网店订单
     */
    @Override
    public TradingOrder selectTradingOrderById(String id)
    {
        return tradingOrderMapper.selectTradingOrderById(id);
    }

    /**
     * 查询网店订单列表
     *
     * @param tradingOrder 网店订单
     * @return 网店订单
     */
    @Override
    public List<TradingOrder> selectTradingOrderList(TradingOrder tradingOrder)
    {
        return tradingOrderMapper.selectTradingOrderList(tradingOrder);
    }

    @Override
    public List<TradingOrder> selectMyTradingOrderList(TradingOrder tradingOrder) {
        tradingOrder.setOrderHolderId(LoginUserUtils.getUserId());
        return tradingOrderMapper.selectMyTradingOrderList(tradingOrder);
    }

    /**
     * 新增网店订单
     *
     * @param tradingOrder 网店订单
     * @return 结果
     */
    @Override
    public int insertTradingOrder(TradingOrder tradingOrder)
    {
        tradingOrder.setCreateTime(DateUtils.getNowDate());
        return tradingOrderMapper.insertTradingOrder(tradingOrder);
    }

    /**
     * 修改网店订单
     *
     * @param tradingOrder 网店订单
     * @return 结果
     */
    @Override
    public int updateTradingOrder(TradingOrder tradingOrder)
    {
        tradingOrder.setUpdateTime(DateUtils.getNowDate());
        return tradingOrderMapper.updateTradingOrder(tradingOrder);
    }

    /**
     * 批量删除网店订单
     *
     * @param ids 需要删除的网店订单主键
     * @return 结果
     */
    @Override
    public int deleteTradingOrderByIds(String[] ids) {
        return tradingOrderMapper.deleteTradingOrderByIds(ids);
    }

    /**
     * 删除网店订单信息
     *
     * @param id 网店订单主键
     * @return 结果
     */
    @Override
    public int deleteTradingOrderById(String id) {
        return tradingOrderMapper.deleteTradingOrderById(id);
    }
}
